#!/usr/bin/env node

const http = require('http');
const {join} = require('path');
const fs = require('fs');
const mem = require('memory-format');


http.createServer((req,res)=>{
    console.time('TEST');
    let file= join(__dirname,req.url);
    if(!fs.existsSync(file)) {
        res.end(`${req.url} not exists!`);
        return;
    }
    
    console.log(mem());
    fs.createReadStream(file).pipe(res);
    console.timeEnd('TEST');
}).listen(8080);
